import 'package:flutter_admin/models/odoo/sale_inquiry_form.dart';
import 'package:flutter_admin/pages/common/cry/cry_all.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_admin/pages/common/cry/cry_button.dart';
import '../../../generated/l10n.dart';

class SaleInquiryFormView extends StatefulWidget {
  SaleInquiryFormView({this.saleInquiryForm});

  final SaleInquiryForm? saleInquiryForm;

  @override
  _SaleInquiryFormViewState createState() => _SaleInquiryFormViewState();
}

class _SaleInquiryFormViewState extends State<SaleInquiryFormView> {
  late SaleInquiryForm saleInquiryForm;

  final GlobalKey<FormState> formKey = GlobalKey<FormState>();
  @override
  void initState() {
    super.initState();
    this.saleInquiryForm = widget.saleInquiryForm ?? SaleInquiryForm();

    _loadSelectVO();
  }

  _loadSelectVO() async {
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    var form = Form(
      key: formKey,
      child: Wrap(
        children: <Widget>[
          CryInput(
            width: 325,
            enable: false,
            label: '报价单位',
            value: '中天宽带技术有限公司',
          ),
          CryInput(
            width: 325,
            enable: false,
            label: '事业部',
            value: saleInquiryForm.deptName,
          ),
          CryInput(
            width: 325,
            label: '询价单编号',
            enable: false,
            value: saleInquiryForm.inquiryNo,
          ),
          CryInput(
            width: 325,
            label: '业务员',
            enable: false,
            value: saleInquiryForm.userName,
          ),
          CryInput(
            width: 325,
            label: '询价单位',
            enable: false,
            value: saleInquiryForm.partnerName,
          ),
          CryInput(
            width: 325,
            label: '电话',
            enable: false,
            value: saleInquiryForm.phone,
          ),
          CryInput(
            width: 325,
            label: '客户性质',
            enable: false,
            value: saleInquiryForm.customerNature,
          ),
          CryInput(
            width: 325,
            label: '邮箱',
            enable: false,
            value: saleInquiryForm.email,
          ),
          CryInput(
            width: 325,
            label: '到货地点',
            enable: false,
            value: saleInquiryForm.arrivalPlace,
          ),
          CryInput(
            width: 325,
            enable: false,
            label: '付费方式',
            value: saleInquiryForm.paymentMethod,
          ),
          CryInput(
            width: 325,
            enable: false,
            label: '项目名称',
            value: saleInquiryForm.projectName,
          ),
          CryInput(
            width: 325,
            enable: false,
            label: '是否有目标价',
            value: saleInquiryForm.isTargetprice == '0'
                ? '否'
                : saleInquiryForm.isTargetprice == '1'
                    ? '是'
                    : '',
          ),
          // 新增字段开始；
          CryInput(
            width: 325,
            enable: false,
            label: '报价币种',
            value: saleInquiryForm.currency,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '下单汇率',
            value: saleInquiryForm.exchangeRate,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '税率',
            value: saleInquiryForm.taxRate,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '利润率',
            value: saleInquiryForm.profitMargin,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '运输费用（元）',
            value: saleInquiryForm.trafficExpense,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '海运费/空运费（元）',
            value: saleInquiryForm.oceanFreight,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '运输保险（元）',
            value: saleInquiryForm.transportationInsurance,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '保函费用（元）',
            value: saleInquiryForm.guaranteeFee,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '熏蒸/热处理费（元）',
            value: saleInquiryForm.heatTreatment,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '报检代理费（元）',
            value: saleInquiryForm.brokerageFee,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '普惠制产地证（元）',
            value: saleInquiryForm.COOFG,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '试验费（元）',
            value: saleInquiryForm.experimentalExpenses,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '认证、公证费（元）',
            value: saleInquiryForm.notarialFees,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '佣金（元）',
            value: saleInquiryForm.commission,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '厂验（元）',
            value: saleInquiryForm.factoryInspection,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '融资费用（元）',
            value: saleInquiryForm.financing,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '信用保险（元）',
            value: saleInquiryForm.creditInsurance,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '施工服务费（元）',
            value: saleInquiryForm.constructionServiceFee,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '其他费（元）',
            value: saleInquiryForm.other,
          ),
          CryInputNum(
            width: 325,
            enable: false,
            label: '资信调查报告费（元）',
            value: saleInquiryForm.surveyReport,
          ),
          // 新增字段结束；
          CryInput(
            enable: false,
            label: '产品描述',
            value: saleInquiryForm.content,
            onSaved: (v) {
              saleInquiryForm.content = v;
            },
          ),
          CryInput(
            label: '备注',
            enable: false,
            value: saleInquiryForm.comment,
          ),
        ],
      ),
    );
    var buttonBar = ButtonBar(
      alignment: MainAxisAlignment.center,
      children: <Widget>[
        CryButton(
          label: S.of(context).confirm,
          onPressed: () {
            Navigator.pop(context);
          },
          iconData: Icons.done_outline,
        ),
      ],
    );
    var result = Scaffold(
      appBar: AppBar(
        title: Text('询价表查看'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [form],
        ),
      ),
      bottomNavigationBar: buttonBar,
    );
    return SizedBox(
      width: 650,
      height: 650,
      child: result,
    );
    // return result;
  }
}
